//
//  GEDCOMEditAppDelegate.m
//  GEDCOMEdit
//
//  Created by Colin Begg on 11/02/2012.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "GEDCOMEditAppDelegate.h"

@implementation GEDCOMEditAppDelegate

@synthesize window = _window;
@synthesize gedcomFile = _gedcomFile;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    // Insert code here to initialize your application
}

- (IBAction)fileOpen:(id)sender {
    NSOpenPanel* panel = [NSOpenPanel openPanel];
    
    // This method displays the panel and returns immediately.
    // The completion handler is called when the user selects an
    // item or cancels the panel.
    [panel beginWithCompletionHandler:^(NSInteger result){
        if (result == NSFileHandlingPanelOKButton) {
            NSURL*  theDoc = [[panel URLs] objectAtIndex:0];
            
            // Open  the document.
            self.gedcomFile = [[GEDCOMFile alloc] initWithContentsOfFileAtURL: theDoc];
        }
        
    }];

}
@end
